﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace yeqw.FrameWork
{
    public static class RegexHelper
    {
        /// <summary>
        /// 获得正则匹配结果信息列表
        /// </summary>
        /// <param name="resultData">匹配信息</param>
        /// <param name="pattern">匹配规则</param>
        /// <returns></returns>
        public static ResultInfo<MatchCollection> GetMatchCollectionResult(string resultData, string pattern)
        {
            Regex regex = new Regex(pattern);
      
            ResultInfo<MatchCollection> result = new ResultInfo<MatchCollection>(true);
            for (int asyncount = 0; asyncount < 2; asyncount++)
            {
                result = AsynchronousRegex.GetAsynRegexMatches(regex, resultData);
                if (!result.IsError)
                {
                    break;
                }
            }
            if (!result.IsError)
            {
                if (result.ResultObject == null || result.ResultObject.Count <= 0)
                {
                    result.IsError = true;
                    result.Description = "无匹配信息";
                    result.ResultCode = "10";
                }
            }
            return result;
        }
      
    }
}
